package com.ionehe.group.common.io.time;

import java.util.Date;
import java.util.TimeZone;
import java.util.function.Function;
import java.util.function.Supplier;

public interface Greenwich {
    int OFFSET = TimeZone.getDefault().getRawOffset();
    Supplier<Date> NOW = () -> {
        return new Date(System.currentTimeMillis() - (long) OFFSET);
    };
    Supplier<Long> NOW_MS = () -> {
        return System.currentTimeMillis() - (long) OFFSET;
    };
    Function<Long, Date> TIME = (offset) -> {
        return new Date(System.currentTimeMillis() - (long) OFFSET + offset);
    };
    Function<Long, Long> TIME_MS = (offset) -> {
        return System.currentTimeMillis() - (long) OFFSET + offset;
    };
    Function<Long, Boolean> MS_BEFORE = (time) -> {
        return time < System.currentTimeMillis() - (long) OFFSET;
    };
    Function<Long, Boolean> MS_AFTER = (time) -> {
        return time >= System.currentTimeMillis() - (long) OFFSET;
    };
    Function<Date, Boolean> TIME_BEFORE = (time) -> {
        return time.getTime() < System.currentTimeMillis() - (long) OFFSET;
    };
    Function<Date, Boolean> TIME_AFTER = (time) -> {
        return time.getTime() >= System.currentTimeMillis() - (long) OFFSET;
    };
}
